<?php
class mlistdetailcontent extends CI_Model{
	var $listdetail = "list_detail_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_listdet,$id_list,$title_listdet,$date_listdet,$text_listdet,$file_listdet)
	{
		$this->id_listdet= $id_listdet;
		$this->id_list= $id_list;
		$this->title_listdet= $title_listdet;
		$this->date_listdet= $date_listdet;
		$this->text_listdet= $text_listdet;
		$this->file_listdet= $file_listdet;
	}
	
	function getList($id_list,$page,$uri_segment){
		$this->db->where('id_list', $id_list);
		$query = $this->db->get($this->listdetail, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->listdetail);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_listdet'=>$this->id_listdet,
			'id_list'=>$this->id_list,
			'title_listdet'=>$this->title_listdet,
			'date_listdet'=>$this->date_listdet,
			'text_listdet'=>$this->text_listdet,
			'file_listdet'=>$this->file_listdet
		);
		return $this->db->insert($this->listdetail, $arrayData);
	}
	
	function update($id_listdet)
	{
		$arrayData = array(
			'id_list'=>$this->id_list,
			'title_listdet'=>$this->title_listdet,
			'date_listdet'=>$this->date_listdet,
			'text_listdet'=>$this->text_listdet,
			'file_listdet'=>$this->file_listdet
		);
		$this->db->where('id_listdet', $id_listdet);
		return $this->db->update($this->listdetail, $arrayData);
	}
        
	function remove($id_listdet)
	{
		$this->db->where('id_listdet', $id_listdet);
		return $this->db->delete($this->listdetail);
	}	
	
	function detail($id_listdet)
	{
		$this->db->where('id_listdet', $id_listdet);
		$query = $this->db->get($this->listdetail);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('title_listdet',$name);
		$query = $this->db->get($this->listdetail);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>